*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Creating Tables for POLS, RE, and FE models					~~~~
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Creating matrix with estimated coefficients and standard errors	
	matrix mean = J(2,18,.)			
	qui: sum POLScon
	matrix mean[1,1]=r(mean)
	qui: sum POLSconse		
	matrix mean[1,2]=r(mean)	
	qui: sum POLSlag
	matrix mean[2,3]=r(mean)
	qui: sum POLSlagse		
	matrix mean[2,4]=r(mean)	
	qui: sum POLSboth_con
	matrix mean[1,5]=r(mean)
	qui: sum POLSboth_conse		
	matrix mean[1,6]=r(mean)	
	qui: sum POLSboth_lag
	matrix mean[2,5]=r(mean)
	qui: sum POLSboth_lagse		
	matrix mean[2,6]=r(mean)
	qui: sum REcon
	matrix mean[1,7]=r(mean)
	qui: sum REconse		
	matrix mean[1,8]=r(mean)	
	qui: sum RElag
	matrix mean[2,9]=r(mean)
	qui: sum RElagse		
	matrix mean[2,10]=r(mean)	
	qui: sum REboth_con
	matrix mean[1,11]=r(mean)
	qui: sum REboth_conse		
	matrix mean[1,12]=r(mean)	
	qui: sum REboth_lag
	matrix mean[2,11]=r(mean)
	qui: sum REboth_lagse		
	matrix mean[2,12]=r(mean)	
	qui: sum FEcon
	matrix mean[1,13]=r(mean)
	qui: sum FEconse		
	matrix mean[1,14]=r(mean)	
	qui: sum FElag
	matrix mean[2,15]=r(mean)
	qui: sum FElagse		
	matrix mean[2,16]=r(mean)	
	qui: sum FEboth_con
	matrix mean[1,17]=r(mean)
	qui: sum FEboth_conse		
	matrix mean[1,18]=r(mean)	
	qui: sum FEboth_lag
	matrix mean[2,17]=r(mean)
	qui: sum FEboth_lagse		
	matrix mean[2,18]=r(mean)			

* True values of x and xlag
	local truex = $betax * (1-$lambdax)
	local truexlag = $betaxlag * $lambdax	
	
* Saving information about scenario
	local obs 		= $obs
	local waves	 	= $waves
	local lambdax	= $lambdax
	local endo		= $endo
	local unob		= $unob

*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Creating Tables for POLS, RE, and FE models					~~~~
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~	
* Saving Table
	frmttable using "$results\n`obs'-t`waves'-x`truex'-xlag`truexlag'-lambdax`lambdax'-endo`endo'-unob`unob'-POLS-RE-FE",statmat(mean) substat(1)						///
		title("Results of $reps Simulations (n=$obs, t=$waves)"									///
		"True effects: x=`truex'; xlag=`truexlag'"												///
		"lambdax=$lambdax | autox=$autox | autoy=$autoy | endo=$endo | unob=$unob")				///
		ctitles("Effect" "POLS" "POLS" "POLS" "RE" "RE" "RE" "FE" "FE" "FE")					///
		rtitle("x"\""\"xlag"\"")																///
		note("Robust SE in Parentheses.")														///
		landscape replace 
		
	

